<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

<c:if test="${userID==null}">
  <c:redirect url="index-msa.jsp" />
</c:if>

<c:if test="${userType!='A'}">
  <c:redirect url="main.jsp" />
</c:if>

<c:if test="${pageContext.request.method=='POST'}">
  <c:if test="${param.cancel!=null}">
    <c:redirect url="admin.jsp" />
  </c:if>

  <sql:update dataSource="${dataSource}">
    update t_forums set c_name = ?, c_sequence = ? where c_code = ? 
  <sql:param value="${param.name}" />

  <sql:param value="${param.seq}" />

  <sql:param value="${param.code}" />
  </sql:update>

  <c:redirect url="admin.jsp" />
</c:if>

<html>
  <head>
    <title>Edit Forum</title>
  </head>

  <body>
    <sql:query var="forums" dataSource="${dataSource}">
    select c_code,c_name,c_sequence from t_forums where c_code = ? 
    <sql:param value="${param.target}" />
    </sql:query>

    <c:forEach var="row" items="${forums.rows}">
      <table border="0">
        <form method="post">
          <tr>
            <td colspan="2" bgcolor="#0000FF">
              <p align="center">
                <b>
                  <font size="4" color="#FFFFFF">Edit Forum</font>
                </b>
              </p>
            </td>
          </tr>

          <tr bgcolor="#FFFF66">
            <td>Forum Code</td>

            <td>
            <c:out value="${row.c_code}" />

            <input type="hidden" name="code"
            value="<c:out value="${row.c_code}"/>"/>
            </td>
          </tr>

          <tr>
            <td>Forum Name</td>

            <td>
            <input type="text" name="name" value="<c:out value="${row.c_name}"/>" 
            size="20" width="10"/>
            </td>
          </tr>

          <tr bgcolor="#FFFF66">
            <td>Sequence Number</td>

            <td>
            <input type="text" value="<c:out value="${row.c_sequence}"/>" 
            size="20" name="seq" width=10></td>
          </tr>

          <tr>
            <td colspan="2">
              <center>
                <input type="submit" name="save" value="Save" />

                <input type="submit" name="cancel"
                value="Cancel" />
              </center>
            </td>
          </tr>
        </form>
      </table>
    </c:forEach>
  </body>
</html>

